/**
 * Created by zhaojm on 15/4/3.
 */
game.GameOverEffect = cc.Class.extend({

    _sprite:null,
    _action : null,
    ctor:function(){

        var winSize = cc.winSize;

        this._sprite = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame('over_light.png'));
        this._sprite.setAnchorPoint(cc.p(0.5, 0.5));
        this._sprite.setScale(1);


        //this._action = new cc.Sequence(
        //   /* new cc.Repeat(*/new cc.Animate(
        //        new cc.Animation([4, 5].map(function (i) {
        //            return cc.spriteFrameCache.getSpriteFrame("effect/" + i + ".png");
        //        }), 0.05)
        //    ), //1),
        //    new cc.CallFunc(this.removeFromLayer)
        //);


        //var frames = [];
        //for(var i = 1; i < 35; i++){
        //    var idx = '';
        //    if(i < 10){
        //        idx = '0' + i;
        //    }else {
        //        idx = i + '';
        //    }
        //    var frame = cc.spriteFrameCache.getSpriteFrame('explosion_' + idx + '.png');
        //    frames.push(frame);
        //}
        //var animation = new cc.Animation(frames, 0.04);
        //
        //var removeFunc =  cc.CallFunc.create(this.removeFromLayer);
        //
        //this._action = new cc.Sequence(new cc.Animate(animation), removeFunc);

    },

    addToLayer : function(layer, pos, callback){
        layer.addChild(this._sprite, 10);
        this._sprite.setPosition(pos);
        //this._sprite.setScale(scale);
        this._action = new cc.Sequence(
            new cc.ScaleTo(2, 60),
            new cc.CallFunc(this.removeFromLayer),
            new cc.CallFunc(callback)
        );
        this._sprite.runAction(this._action);
    },

    removeFromLayer : function(pSender){
        pSender.removeFromParent();
    },



});